package org.opensmile.study.Thread;

import java.sql.Time;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class LiftOff implements java.lang.Runnable{

	protected int countDown =10;  //Default
	
	private static int taskCount =0;
	
	private final int id =taskCount++;
	
	public LiftOff(){
		
	}
	
	public LiftOff(int countDown){
		this.countDown=countDown;
	}
	
	
	public String status (){
		return "#"+id+"(" +(countDown >0 ? countDown: "LiftOff!")+").";
	}
	
	public void run() {
		// TODO Auto-generated method stub
		while(true){
			System.out.println(status());
			Thread.yield();
		}
	}

	public static void main(String[] args) {
	/*	for(int i=0 ;i<5;i++)
		new Thread(new LiftOff()).start();*/
/*		ExecutorService es =Executors.newCachedThreadPool();
		for(int i=0 ;i<5;i++){
			es.execute(new LiftOff());
		}		
		es.shutdown();
*/	
/*		for(int i=0 ;i<5;i++)
	*/
		Thread tt =new Thread(new LiftOff());
		tt.setDaemon(true);
		tt.start();
		try {
			TimeUnit.SECONDS.sleep(10);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
